#include <QtPlugin>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QDoubleSpinBox>
#include <QSpinBox>
#include <QPushButton>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include <QComboBox>

#include <opencv/cv.h>
#include <opencv/highgui.h>

#include "QCVModuleInterface.h"
#include "QCVModuleHandlerInterface.h"

#ifndef MODULE_CONVOLUTE
#define MODULE_CONVOLUTE

typedef QDoubleSpinBox * pQDoubleSpinBox;

/**
@class ModuleConvolute
@brief Module de convolution gestion d'un noyau de convolution.
*/

class ModuleConvolute:public QObject,QCVModuleInterface
{
  Q_OBJECT
	Q_INTERFACES(QCVModuleInterface)
	
	public:
		void init(QCVModuleHandlerInterface * parent);
		void free();

		cv::Mat & process();
		void setInput(int n,const cv::Mat & m);

		QWidget* widget();
		QString getName();
		int nbInputs();
		QString help(int id);

		bool setParams(QString params);
		QString getParams();
   
		void direct_load(QString filename);

		QCVModuleInterface * clone();

  public slots:
    void updateGridLayout(int);
    void getMat(int);
    void getMat(double);
    void s_load();
    void s_save();
    
  private:
		QString matfile;
    QWidget * win;
    QVBoxLayout * layout;
    QGridLayout * gridLayout;
    
    QPushButton *bp_load,*bp_save;

    QCVModuleHandlerInterface * parent;
    
    QDoubleSpinBox * sb_fact;
    QSpinBox  *dimX,*dimY;
    QList<pQDoubleSpinBox> kernel_data;
    cv::Mat_<float> kernel;
    cv::Mat frame;
    
};

#endif
